{extend name="layout/dialog" /}

{block name="content"}
<div class="panel panel-default">
    <div class="panel-heading">
        {:__('Assign Permission to Departments')}
    </div>
    <div class="panel-body">
        <form id="department-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('permission/departments')}">
            <input type="hidden" name="permission_id" value="{$permission.id}">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Permission')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="form-control-static">
                        {$permission.name} ({$permission.code})
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Data Scope')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <select name="data_scope" class="form-control selectpicker">
                        {foreach name="dataScopeList" item="name" key="value"}
                            <option value="{$value}">{$name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Departments')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <select name="department_ids[]" class="form-control selectpicker" multiple>
                        {foreach name="departmentList" item="dept"}
                            <option value="{$dept.id}" {in name="dept.id" value="$selectedDepartments"}selected{/in}>
                                {$dept.name} ({$dept.code})
                            </option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group layer-footer">
                <label class="control-label col-xs-12 col-sm-2"></label>
                <div class="col-xs-12 col-sm-8">
                    <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>
                    <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="script"}
<script>
    $(function () {
        Form.api.bindevent($('#department-form'));
    });
</script>
{/block} 